﻿using System;

namespace ProjectEuler
{
    internal class Problem4
    {
        public void Solve()
        {
            var product = 0;
            for (var i = 999; i > 0; i--)
            {
                for (var j = 999; j > 0; j--)
                {
                    var prod = i*j;
                    if (IsPalindrome(prod.ToString()) && prod > product)
                    {
                        product = prod;
                    }
                }
            }

            Console.WriteLine("problem 4: " + product);
        }

        private bool IsPalindrome(string str)
        {
            for (var i = 0; i < str.Length/2; i++)
            {
                if (str[i] != str[str.Length - 1 - i])
                    return false;
            }

            return true;
        }
    }
}